﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Workflow.Domain.Enums;

namespace Workflow.Domain.Models
{
    /// <summary>
    /// 流程模板表
    /// </summary>
    [Table(nameof(WorkflowDefinitionModel))]
    public class WorkflowDefinitionModel:BaseEntity
    {
        /// <summary>
        /// 流程模板标题/描述
        /// </summary>
        public string Title { get; set; } = null!;
        /// <summary>
        /// 流程模板版本
        /// </summary>
        public int Version { get; set; }
        /// <summary>
        /// 工作流定义ID（和版本配合用来完成流程查找）
        /// </summary>
        public string WorkflowDefinitionId { get; set; } = null!;
        /// <summary>
        /// 模板组编号
        /// </summary>
        public long GroupId {  get; set; }
        /// <summary>
        /// 流程步骤之间数据传递数据类型表单(从前端序列号传进来)
        /// </summary>
        [Column(TypeName = "json")]
        public string DataType { get; set; } = null!;
        /// <summary>
        /// 流程步骤（实际是List<WorkflowStepNode>的序列化）
        /// </summary>
        [Column(TypeName = "json")]
        public string StepNodes { get; set; } = null!;
        /// <summary>
        /// 发起人限制（0是所有人,其他的会限制角色）
        /// </summary>
        public long Promoter {  get; set; }
    }
    /// <summary>
    /// 流程步骤表
    /// </summary>
    public class WorkflowStepNode
    {
        /// <summary>
        /// 执行步骤ID
        /// </summary>
        public string StepId { get; set; } = null!;
        /// <summary>
        /// 下一个步骤ID
        /// </summary>
        public string NextStepId { get; set; } = null!;
        /// <summary>
        /// 步骤名称
        /// </summary>
        public string StepName { get; set; } = null!;
        /// <summary>
        /// 工作流详细步骤信息
        /// </summary>
        public WorkflowStepNodeDetail StepNodeDetail { get; set; } = null!;
    }
    /// <summary>
    /// 工作流详细步骤信息
    /// </summary>
    public class WorkflowStepNodeDetail
    {
        /// <summary>
        /// 节点审批类型
        /// </summary>
        public NodeAuditTypeEnum NodeAuditEnum {  get; set; }
        /// <summary>
        /// 当审批人与提交人为同一人时枚举:1-自己审批  2-跳过任务
        /// </summary>
        public ApproverAndSubmitterEnum ApproverEnum {  get; set; }
        /// <summary>
        ///  审批方式: 1-单人审批  2-多人审批(会签)
        /// </summary>
        public HandleTypeEnum HandleType { get; set; }
        /// <summary>
        /// 会签规则 1-全部审批通过 2-半数审批通过 3-任意一个审批通过 (单签审批时该属性无效)
        /// </summary>
        public HandleCountersignTypeEnum HandleCountersignType { get; set; }
        /// <summary>
        /// 会签方式  1-并行会签 2-串行会签 (单签审批时该属性无效)
        /// </summary>
        public CounterSignTypeEnum CounterSignType { get; set; }
        /// <summary>
        /// 审批人列表（有可能指的是角色ID）
        /// </summary>
        public List<long> AuditPersons { get; set; } = null!;
    }
}
